<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img src=" "
        alt="">

    <input type="file" name="" id="aa" onchange='dodo()'>
    <script>
        function dodo() {
            let myfile = document.querySelector('#aa').files[0]
            console.log(myfile)
        }
    </script>
    <!-- 正则：校验用户输入的数据，数据的类型只能是字符串 -->
    <script>
    // let str = prompt('请输入内容')
    // 创建正则进行验证
    // let reg = new RegExp()
    // let reg = /./
    // let reg = /^\d$/
    // let reg = /^\D$/
    // let reg = /^\w$/
    // let reg = /^\W$/
    // let reg = /\W/
    // let reg = /^\s$/
    // let reg = /^[35789]$/
    // let reg = /^[6-3]$/
    // let reg = /^[0-9a-zA-Z_]$/
    // let reg = /^\d*$/
    // let reg = /^\d?$/
    // let reg = /^\w+$/
    // let reg = /^[1-9]\d{16}[0-9xX]$/
    // let reg = /^1[35789]\d{9}$|^1\d{4}$/
    // let reg = /^{4}$/

    // // wuhu0723@126.com
    // let reg = /^\w+[@]\w+[.]\w{2,4}$/

    // // 调用正则进行验证,test可以使用指定的正则校验指定的字符串，如果校验通过则返回true,否则返回false
    // let res = reg.test(str)
    // console.log(res)
    </script>
</body>

</html>